package com.ssy.lingxi.contract.model.constant;

import com.ssy.lingxi.common.language.LanguageHolder;
import com.ssy.lingxi.contract.model.vo.common.response.StatusItemVO;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 合同甲方内部状态
 * @author 伍将
 * @date 2021/2/3
 * @version 2.0.0
 */
public enum  ContractPartyBInnerStatusEnum {

    ALL(0, "所有状态"),
    TO_BE_SUBMIT_EXAMINE(1, "待提交审核合同"),
    TO_BE_EXAMINE_1(2, "待审核合同(一级)"),
    SUBMIT_EXAMINE_NO_PASS(3, "合同审核不通过(提交)"),
    TO_BE_EXAMINE_2(4, "待审核合同(二级)"),
    EXAMINE_NO_PASS_1(5, "合同审核不通过(一级)"),
    EXAMINE_PASS_2(6, "合同审核通过(二级)"),
    EXAMINE_NO_PASS_2(7, "合同审核不通过(二级)"),
    AGREE_SIGN_CONTRACT(8, "同意签订合同"),
    DISAGREE_SIGN_CONTRACT(9, "不同意签订合同");

    private final Integer code;
    private final String message;

    ContractPartyBInnerStatusEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getClass(), this.code);
    }

    public static String getMessage(Integer code) {
        return Arrays.stream(ContractPartyBInnerStatusEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(ALL).getMessage();
    }

    /**
     * 获得所有状态项列表
     * @param excludeCodes 排除的code/不排除传null
     * @return
     */
    public static List<StatusItemVO> all(List<Integer> excludeCodes){
        Stream<ContractPartyBInnerStatusEnum> stream = Arrays.stream(ContractPartyBInnerStatusEnum.values());
        if(excludeCodes!=null&&excludeCodes.size()>0){
            stream=stream.filter(o->!excludeCodes.contains(o.getCode()));
        }
        return stream.map(o ->{
            StatusItemVO vo=new StatusItemVO();
            vo.setCode(o.getCode());
            vo.setMessage(o.getMessage());
            return vo;
        }).collect(Collectors.toList());
    }

}
